// 云函数入口文件
const cloud = require('wx-server-sdk')
const axios = require("axios")

cloud.init({
    env: "malu-9gjr8vrn08c2dfb4"
}) // 使用当前云环境

let db = cloud.database();
let yinyue = db.collection("yinyue");

// 云函数入口函数
exports.main = async (event, context) => {
    let songs = await axios.get("http://47.94.210.129:3002/personalized")
    console.log("songs:", songs.data.result);
    for (let item of songs.data.result) {
        await yinyue.add({
            data: item
        }).then(res => {
            console.log("插入成功");
        })
    }
    return "保存数据成功"
}